#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    timer = new QTimer;
    picID = 1;
    QImage Img;
    Img.load("/home/eleven/Pictures/Screenshots/1.png");
    ui->label->setPixmap(QPixmap::fromImage(Img));

    connect(timer,&QTimer::timeout,this,&Widget::timeoutSlot);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_startbutton_clicked()
{
    timer->start(TIME_OUT);
}

void Widget::timeoutSlot()
{
    picID++;
    QString path("/home/eleven/Pictures/Screenshots/");
    path += QString::number(picID);
    path += ".png";
    QImage img;
    img.load(path);
    ui->label->setPixmap(QPixmap::fromImage(img));


    if (5 == picID)
    {
        picID = 0;
    }

}


void Widget::on_stopbutton_clicked()
{
    timer->stop();
}


void Widget::on_singlebutton_clicked()
{
    Widget::timeoutSlot();

}

